package com.globallogic.dailyplanner.utils;

import java.util.Date;

import javax.faces.application.FacesMessage;
import javax.faces.validator.ValidatorException;

public class DateUtil {
	public static void beforeNow(Date date, String msgStr) {
		Date currentDate = new Date();
		if (date.before(currentDate)) {
			FacesMessage msg = new FacesMessage("Date validation failed.",
					msgStr);
			msg.setSeverity(FacesMessage.SEVERITY_ERROR);
			throw new ValidatorException(msg);
		}
	}

	public static void endBeforeStart(Date date1, Date date2, String msgStr) {
		if (date1.before(date2)) {
			FacesMessage msg = new FacesMessage("Date validation failed.",
					msgStr);
			msg.setSeverity(FacesMessage.SEVERITY_ERROR);
			throw new ValidatorException(msg);
		}
	}
}
